package net.csdn.business.common.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author likun
 * @date 2022/6/25 16:48
 */
public interface InvitationEnum {
    @Getter
    @AllArgsConstructor
    enum TargetTypeEnum {
        /**
         * 项目邀请
         */
        PROJECT(1, "project", "代码库"),
        /**
         * 组织邀请
         */
        ORG(2, "org", "组织"),
        /**
         * 组织向上关联申请
         */
        ORG_RELATION(3, "orgRelation", "组织向上关联"),
        /**
         * 组织向下关联申请
         */
         //ORG_DOWN_RELATION(4, "orgRelation", "组织向下关联"),
        ;
        private final int type;
        private final String code;
        private final String desc;

        public static TargetTypeEnum ofType(int type) {
            for (TargetTypeEnum targetType : TargetTypeEnum.values()) {
                if (targetType.type == type) {
                    return targetType;
                }
            }
            throw new IllegalArgumentException("InvitationEnum#TargetTypeEnum param error");
        }
    }

    @Getter
    @AllArgsConstructor
    enum StatusEnum {
        /**
         * 正常
         */
        NORMAL(0, "正常"),
        PASS(1, "通过"),
        REJECT(2, "拒绝"),
        REVORK(3, "撤销"),
        ;

        final int code;
        final String desc;

        public static StatusEnum ofCode(int code) {
            for (StatusEnum statusEnum : StatusEnum.values()) {
                if (statusEnum.code == code) {
                    return statusEnum;
                }
            }
            throw new IllegalArgumentException("InvitationEnum#StatusEnum param error");
        }
    }

}
